package fr.enseirb.mycub.activity.component;

import java.util.List;

import android.content.Context;
import android.location.Location;
import android.util.Log;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import fr.enseirb.mycub.component.map.bike.MyLocationOverlay;

public class MyLocationComponent {

	private MyLocationOverlay mMyLocationOverlay = null; 
	
	public MyLocationComponent(Context context, MapView mMapView, List<Overlay> mMapOverlays){
		Log.i(this.getClass().getCanonicalName(), "myLocationComponent");
			mMyLocationOverlay = new MyLocationOverlay(context, mMapView);
			mMapOverlays.add(mMyLocationOverlay);
	}

public  void resetPosition(){
	mMyLocationOverlay.setCurrentLocation(null);
}

public  void onLocationChanged(Location location){
	if(location != null){
		Log.i(this.getClass().getCanonicalName(), "onLocationChanged : "+location.getAccuracy());
		mMyLocationOverlay.setCurrentLocation(location);
	}
}

public  GeoPoint getMyLocation(){
	Log.i("MyLocationComponent", "geopoint: "+mMyLocationOverlay.getMyLocation());
	return mMyLocationOverlay.getMyLocation();
}

public  boolean isMyLocationDrawn(){
	return mMyLocationOverlay.isMyLocationDrawn();
}

}
